package com.auto.autoapp.ui.activity

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.auto.autoapp.R
import com.auto.autoapp.adapter.UrlManageAdapter
import com.auto.autoapp.base.BaseActivity
import com.auto.autoapp.databinding.ActivityUrlManageBinding
import com.auto.autoapp.util.UrlManageUtil
import com.auto.autoapp.widgets.SimpleToolbar

class UrlManageActivity : BaseActivity() {
    companion object {
        const val SOURCE_TYPE = "SOURCE_TYPE"
        const val TYPE_USER = "TYPE_USER"
        const val TYPE_LIVE = "TYPE_LIVE"
    }

    private val urlAdapter = UrlManageAdapter()
    private var isUserType = false

    private lateinit var binding: ActivityUrlManageBinding
    override fun provideView(): View {
        binding = ActivityUrlManageBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun configToolbar(toolbar: SimpleToolbar) {
        super.configToolbar(toolbar)
        toolbar.funView.apply {
            setImageResource(R.drawable.ic_add)
            setOnClickListener {
                addUrl()
            }
        }
    }

    fun addUrl() {

    }

    override fun onInit() {
        isUserType = intent.getStringExtra(SOURCE_TYPE) == TYPE_USER
        binding.rvUrl.apply {
            layoutManager = LinearLayoutManager(this@UrlManageActivity)
            adapter = urlAdapter
        }
        urlAdapter.setList(if (isUserType) UrlManageUtil.userUrlList else UrlManageUtil.liveUrlList)
    }


}